#include "widget.h"
#include "ui_widget.h"

#include <QPixmap>
#include <QPainter>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    (void) event;
    QPainter painter(this);

    painter.drawPixmap(100, 100, 100, 50, QPixmap(":/cat.jpg"));

    painter.translate(100, 100);
    painter.drawPixmap(200, 200, 100, 50, QPixmap(":/cat.jpg"));

    painter.rotate(180);
    painter.drawPixmap(-300, -300, 100, 50, QPixmap(":/cat.jpg"));

    painter.translate(-100, -100); // 原点复原
}

